# coding=utf-8
import time
from framework.base_page import BasePage
from framework.logger import MyLog

# 实例化日志
log = MyLog.get_log()
logger = log.getlog()

class Login(BasePage):

    # 会员图标
    personal_center_icon = 'name,会员'
    # 个人中心的登录按钮
    btn_login_now = 'name,立即登录'
    #登录方式改变 密码登录
    btn_login_password = 'name,密码登录'

    # 登录页的输入框和登录按钮
    input_phone_number = 'id,com.gelonghui.glhapp:id/et_phone_number'
    input_phone_passswd = 'id,com.gelonghui.glhapp:id/et_psw'

    #执行登录按钮
    btn_login_now2 = 'id,com.gelonghui.glhapp:id/tv_login'

    # 登录
    def login(self):
        time.sleep(5)
        # 点击导航中间的"会员"图标
        print("\n" + self.personal_center_icon)
        self.click(self.personal_center_icon)

        logger.info('点击导航中间的"会员"图标')
        time.sleep(3)
        #  点击"立即登录"按钮
        self.click(self.btn_login_now)
        logger.info('在个人中心点击"立即登录"按钮')
        time.sleep(3)
        #改变登录方式：密码登录
        self.click(self.btn_login_password)
        logger.info('改变登录方式：密码登录')
        time.sleep(3)
        #
        # 在账号输入框输入账号
        self.click(self.input_phone_number)
        self.send_str(self.input_phone_number, "你的账号")
        logger.info('输入账号')
        time.sleep(2)
        # 在密码输入框输入密码
        # self.click(self.input_phone_passswd)
        self.send_str(self.input_phone_passswd, "aa123321")
        logger.info('输入密码')
        time.sleep(1)
        # 点击登录页"登录"按钮
        self.click(self.btn_login_now2)
        logger.info('在登录页点击"登录"按钮')
        time.sleep(10)

    # # 加验证的登录
    # def check_login(self):
    #     # 点击左上方"个人中心"图标
    #     self.click(self.personal_center_icon)
    #     logger.info('点击左上方"个人中心"图标')
    #     time.sleep(2)
    #     # check图标
    #     self.check_element(self.icon_me_message)
    #     self.check_element(self.icon_me_home)
    #     self.check_element(self.icon_me_sent)
    #     self.check_element(self.icon_me_collect)
    #     self.check_element(self.icon_me_sub)
    #     self.check_element(self.icon_me_setting)
    #     self.check_element(self.icon_me_feedback)
    #     self.check_element(self.icon_me_about)
    #     # check按钮名称
    #     self.check_element(self.me_message_name)
    #     self.check_element(self.me_home_name)
    #     self.check_element(self.me_sent_name)
    #     self.check_element(self.me_collect_name)
    #     self.check_element(self.me_sub_name)
    #     self.check_element(self.me_setting_name)
    #     self.check_element(self.me_feedback_name)
    #     self.check_element(self.me_about_name)
    #     # 检查未登录跳转登录页
    #     # 消息中心
    #     self.click(self.me_message_button)
    #     time.sleep(1)
    #     self.check_element(self.login_page_title)
    #     logger.info('未登录----消息中心跳转登录页成功')
    #     self.click(self.loginpage_back_button)
    #     time.sleep(1)
    #     # 我的主页
    #     self.click(self.me_home_button)
    #     time.sleep(1)
    #     self.check_element(self.login_page_title)
    #     logger.info('未登录----消息中心跳转登录页成功')
    #     self.click(self.loginpage_back_button)
    #     time.sleep(1)
    #     # 我的发表
    #     self.click(self.me_sent_button)
    #     time.sleep(1)
    #     self.check_element(self.login_page_title)
    #     logger.info('未登录----消息中心跳转登录页成功')
    #     self.click(self.loginpage_back_button)
    #     time.sleep(1)
    #     # 我的收藏
    #     self.click(self.me_collect_button)
    #     time.sleep(1)
    #     self.check_element(self.login_page_title)
    #     logger.info('未登录----消息中心跳转登录页成功')
    #     self.click(self.loginpage_back_button)
    #     time.sleep(1)
    #     # 我的订阅
    #     self.click(self.me_sub_button)
    #     time.sleep(1)
    #     self.check_element(self.login_page_title)
    #     logger.info('未登录----消息中心跳转登录页成功')
    #     self.click(self.loginpage_back_button)
    #     time.sleep(1)
